home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: Targeting objects in scripts
- Sent: 6/13/96 11:50 AM
- Received: 6/13/96 11:01 AM
- From: Greg Friedman, friedman@cognosis.com
- Reply-To: ODF Interest, ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- Scott Daniels asked:
- > I am fairly new to scripting, so please forgive any ignorance I may show.
- >My question is this: I have been told that one can write a script like:
- >
- > Set Position of Shape whose Color is {0,0,0} to {50,25}
- >
- > In this script, the shape is specified via its color property. Upon
- >examination of FWMScriptable >however, I can only specify elements by
- >index et. al. and the name property only. Does the OpenDoc
- > scripting archictecture support object specification by any object
- >property? If it does, then
- >do I need to override GetContainedObject in order to resolve objects by
- >properties other than name?
-
- This sort of thing works in ODF without much effort. When the direct object
- of an apple event is a "whose clause", the target of the event's object
- accessor is called with a specifier of form whose. The application or part
- has two options: resolve the whose clause itself, or return
- errAEEventNotHandled in response to the object access, and let the OSL
- resolve the whose clause.
-
- Greg Anderson wrote an article for an issue of Develop that describes a
- method for resolving whose clauses manually. In most cases, its a lot of
- work, and you don't get a justifiable performance improvement. ODF does not
- resolve whose clauses manually, it relies on the OSL.
-
- The OSL resolves whose clauses as follows:
-
- Calls your count proc to determine the number of objects of the class being
- specified in the whose clauses.
- Calls your object accessor for each of the possible objects, specificing
- each object by index.
- For each object, the property or properties being tested are requested.
- For each property, your compareproc is called, and the truth of the whose
- clause is assessed.
- For each object that meets the specifications of the whose clause, the
- object is added to a collection.
-
- Once the collection of satisfactory objects has been established, the event
- is dispatched to your event handler with the collection as the direct
- object.
-
- ODF makes most of this work automatically. To support the whose clause you
- posed, your shape object must do the following:
-
- Implement "HasProperty" and return TRUE for pColor and pPosition.
- Implement "GetProperty" and return pColor when requested.
- Implement "SetProperty" and set pPosition when appropriate.
-
- Everything else is automatic, including full undo/redo support.
-
- gsf.
-
-
- ___________________________________________________________
- Greg Friedman ODF Engineering
- Apple Computer
-
-